package com.wm.wmim.common.utils;

import java.util.Collection;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author weiming
 * @date 2024/9/1 14:04
 * @description
 */
public class MyCollectionUtils {

    public static <T, K> Map<K, T> toMap(Collection<T> list, Function<? super T, ? extends K> keyMapper) {
        Map<K, T> collect = list.stream().collect(Collectors.toMap(keyMapper, Function.identity(), (o1, o2) -> o1));
        return collect;
    }

}
